package com.ykt.mall.ctrl;

import java.util.Date;

import com.jfinal.aop.Before;
import com.jfinal.ext.route.ControllerBind;
import com.ykt.interceptor.Seach;
import com.ykt.mall.interceptor.LoginInterceptor;
import com.ykt.model.FrontOrder;

@ControllerBind(controllerKey="/front")//viewPath="/template"
@Before(LoginInterceptor.class)
public class FrontOrderCtrl extends BaseWebController<FrontOrder> {
	
	public void index(){
		
	}
	public void add(){
	}
	@Before(Seach.class)
	public void getBookList(){
		Seach seach= getAttr("seachBean");
		int page = this.getParaToInt("pageindex");
		int rows = this.getParaToInt("pagesize");
		
		filterCustomer(seach);
		
		this.renderJson(FrontOrder.dao.paginate(page, rows, seach));
	}
	public void save(){
		
		FrontOrder fo = getModel(FrontOrder.class);
		fo.set("create_time", new Date());
		fo.set("update_time", new Date());
		fo.set("shop_name", getShop().get("name"));
		fo.set("status", 0);
		fo.set("front_money_status", 0);
		fo.set("customer_id", getLoginCustomer().get("id"));
		fo.save();
		
		redirect("/front");
	}
	
}
